<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
  <link rel="stylesheet" href="css/register.css">
</head>
<body>
    <form action="register.php" method="post">
        <label for="username">用户名:</label>
        <input type="text" id="username" name="username" required><br><br>
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required><br><br>
        <label for="email">邮箱:</label>
        <input type="email" id="email" name="email" required><br><br>
        <input type="submit" value="注册">
    </form>
</body>
<script>
   $(function (){
       $('#registerForm').on('submit', function(event) {
           // 获取表单元素的值
           var username = $('#username').val();
           var password = $('#password').val();
           var email = $('#email').val();

           // 非空校验
           if (username.trim() === '' || password.trim() === '' || email.trim() === '') {
               alert('所有字段都必须填写');
               event.preventDefault(); // 阻止表单提交
           }
       });
   });
</script>
</html>